<template>
  <div class="common-layout" id='imgtxtrpt'>
    <el-container>
      <el-header>
        <h1>细胞学检测报告单</h1>
        <sapn>细胞号：C20200000578</sapn>
      </el-header>
      <el-main>
        <el-descriptions column='4' :size='size'>
          <el-descriptions-item label="姓       名：" >某某某</el-descriptions-item>
          <el-descriptions-item label="性别："  >女</el-descriptions-item>
          <el-descriptions-item label="年龄："  >31岁</el-descriptions-item>
          <el-descriptions-item label="病历号："  >
            00664764
          </el-descriptions-item>

        </el-descriptions>
        <el-descriptions column='4' :size='size'>
          <el-descriptions-item label="送检单位："  >浙江大学医学院附属第一医院</el-descriptions-item>
          <el-descriptions-item label=""   ></el-descriptions-item>
          <el-descriptions-item label=""   ></el-descriptions-item>
          <el-descriptions-item label="住院号："  >
            00664764
          </el-descriptions-item>
          <el-descriptions-item label="送检科室："  >
            肿瘤外科-1190100
          </el-descriptions-item><el-descriptions-item label=""   ></el-descriptions-item>
          <el-descriptions-item label=""   ></el-descriptions-item>
          <el-descriptions-item label="床    号："  >
            30212
          </el-descriptions-item>
        </el-descriptions>
        <el-row class='imgArea'>
          <el-descriptions :size='size'>
            <el-descriptions-item label="镜下所见：">
              <p>
                <img src='http://localhost:5041/image/2024-06-03/BC5180/2024-06-03BC51801000BC5180%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20241105115935.png'>
                <img src='http://localhost:5041/image/2024-06-03/BC5180/2024-06-03BC51801000BC5180%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20241105115935.png'>

              </p>
            </el-descriptions-item>
          </el-descriptions>
          <el-descriptions :size='size' column='1'>
            <el-descriptions-item label="特殊检查：">
              <p class='textArea'>

              </p>
            </el-descriptions-item>
            <el-descriptions-item label="细胞学结果：">
              <p class='textArea'>(左侧甲状腺结节穿刺涂片)找到少量滤泡上皮，分化良好，未见恶性证据
              </p>
            </el-descriptions-item>
            <el-descriptions-item label="备注：">
              <p class='textArea'>

              </p>
            </el-descriptions-item>
          </el-descriptions>
        </el-row>
        <el-descriptions column='3' :size='size'>
          <el-descriptions-item label="初诊医生：" >尤启汉</el-descriptions-item>
          <el-descriptions-item label="审核医生："  >尤启汉</el-descriptions-item>
          <el-descriptions-item label="报告日期："  >2020-10-20</el-descriptions-item>
        </el-descriptions>
      </el-main>
      <el-footer>
        <el-descriptions :size='size'>
          <el-descriptions-item label="注   意   事   项：">
            <p>
              1、细胞学判读结果，只反映肿块局部区域的性质与类型，具有局限性和不确定性，故仅供临床参考，不作确诊、手术和治疗的最终依据。
              <br/>
              2、如细胞学判读结果与临床不符，请立即与病理科联系
              <br/>
              3、如细胞学判读结巢与病理诊断不符以病理诊断为最终诊断结果。
              <br/>
              4、拿到报告后请及时就诊或联系临床医生。
            </p>
          </el-descriptions-item>
        </el-descriptions>
      </el-footer>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
// 引入组件区 ==========
import {
  ref,
  reactive,
  watch,
  getCurrentInstance,
  PropType,
  onMounted
} from 'vue';
import { IsEmpty, formatDateTime } from '@/utils/common'; //导入工具函数
import { VxeMessage, VxeNotifyType } from '@/utils/CommonMessage';
import { funBdsJsResult } from '@/utils/Expression'; //函数公式
import SelectDataGrid from '@/components/SelectDataGrid.vue';
import { AppStore } from '@/stores/store';
import {  FormInstance } from 'element-plus';
import type { ComponentSize } from 'element-plus'
import {
  samstoFridgeLayerAdd,
  samstoFridgeLayerEdit
} from '@/views/lab_sys/samsto_set/apis/samsto_api';

// 全局变量定义区 ==========
let { proxy }: any = getCurrentInstance();
let store = AppStore();
let orgId = ref(null);
const formRef = ref<FormInstance>; //表单ref标记
const size = ref<ComponentSize>('large')

// 表单绑定的数据类型限制
interface FormDataVO {
  id: string /*主键*/;
  layerCode: String ;/*编号 */
  layerBarcode: String ;/*条码号 */
  supportTemp: String ;/*支持温度 */
  currentTemp: String ;/*当前温度 */
  boxTypesRange: String ;/*支持标本盒类型 */
  layerType: String ;/*类型 */
  layerSize: String ;/*尺寸 */
  fridgeId: String ;/*冰箱 */
  layerSeq: String ;/*位置排序 */
  status: Number ;/*状态 */
  deptName: String ;/*所属科室 */
}
// 表单绑定的数据
let formData = reactive<FormDataVO>({
  id: '',
  layerCode: '' ,/*编号 */
  layerBarcode: '' ,/*条码号 */
  supportTemp: '' ,/*支持温度 */
  currentTemp: '' ,/*当前温度 */
  boxTypesRange: '' ,/*支持标本盒类型 */
  layerType: '' ,/*类型 */
  layerSize: '' ,/*尺寸 */
  fridgeId: '' ,/*冰箱 */
  layerSeq: '' ,/*位置排序 */
  status: 1 ,/*状态 */
  deptName: '' ,/*所属科室 */
});
let types = reactive([]);
let fridgeId=ref("");
// 表单校验规则
const formRules: any = {
  layerCode:[{ required: true, message: '请输入编号' }],
  layerBarcode:[{ required: true, message: '请输入条码号' }]
};


defineExpose({
  addNew,
  saveForm,
  initPage
});

// 父组件传值
let props = defineProps({
  fridgeId: { type: String as PropType<any>, required: true },
  currentRow: { type: Object as PropType<any>, required: true }
}) as any;
watch(
  () => props.currentRow,
  (nval, oval) => {
    Object.assign(formData, nval);
  },
  {
    deep: true,
    immediate: true
  }
);
watch(
  () => props.fridgeId,
  (nval, oval) => {
    fridgeId.value=nval;
  },
  {
    deep: true,
    immediate: true
  }
);


onMounted(() => {
  orgId = store.userInfo.orgId;
  //formData.bankNumber=generateCode();
});


// 方法定义区 =============
//生成题库编码
function generateCode() {
  let now = new Date();
  console.log(now,"now");
  let y = now.getFullYear(),
    m = now.getMonth() + 1,
    d = now.getDate(),
    h = now.getHours(),
    mm = now.getMinutes(),
    s = now.getSeconds(),
    ms = now.getMilliseconds();
  return "TM"+y + m+d+h+mm+s+ms;
}
function addNew(callback: any) {
  clear();
  if (callback) {
    callback({ a: '初始化完成' });
  }
}
// 清空表单
function clear() {
  //formData.startus = 1;
  //formData.bankNumber = generateCode();
  //formData.seq = 1;
  formData.id = "";
  formData.layerCode= '' ;/*编号 */
  formData.layerBarcode= '' ;/*条码号 */
  formData.supportTemp= '' ;/*支持温度 */
  formData.currentTemp= '' ;/*当前温度 */
  formData.boxTypesRange= '' ;/*支持标本盒类型 */
  formData.layerType= '' ;/*类型 */
  formData.layerSize= '' ;/*尺寸 */
  formData.fridgeId= fridgeId.value ;/*冰箱 */
  formData.layerSeq= '' ;/*位置排序 */
  formData.status= 1 ;/*状态 */
  formData.deptName= '' ;/*所属科室 */
}

// 保存信息
function saveForm() {
  submitForm();
}
function initPage (selsectRow:any){
  Object.assign(formData, selsectRow);
  fridgeId.value=selsectRow.id;
}
// 保存
const submitForm = () => {
  let elInfo = proxy.$refs.formRef;
  formData.fridgeId=fridgeId.value;
  elInfo.validate(async (valid: any) => {
    if (!valid) {
      return false;
    }
    let res: any;
    if (IsEmpty(formData.id)) {
      res = await samstoFridgeLayerAdd(formData);
    } else {
      res = await samstoFridgeLayerEdit(formData);
    }
    res.status.code === 1 ? VxeMessage(res.status.msg, VxeNotifyType.success) : VxeMessage(res.status.msg, VxeNotifyType.error);
    clear();
    proxy.$emit('findList');
  });
};
// function selectRow(e, rowIndex) {
//   if (!IsEmpty(e)) {
//     formData.deptName = e.code;
//   }
// };
// const states = [
//   {
//     value: 1,
//     label: '启用'
//   },
//   {
//     value: 0,
//     label: '停用'
//   }
// ];

</script>

<style lang="scss" scoped>
#imgtxtrpt{
  height: calc(80vh - 10px);
  padding: 21px;
  overflow: auto;
  // 中等尺寸时 配置扩展属性按钮
  .el-button--default {
    padding: 5px 11px;
  }
  .el-header{
    background-color: #ffffff !important;
    border-bottom-color: #333333;
    border-bottom-style: inset;
    text-align:center;
    height: 110px !important;
    h1{
      color: #333333;
      font-size: 28px;
      margin-block-start: 28px;
      margin-block-end: 16px;
    }
    sapn{
      float: right;
      line-height: 32px;
      font-size: 14px;
      color: #333333;
      padding-right: 15px;
    }
  }
  .el-main{
    border-bottom: inset #333333;
    margin-top: 8px;
    font-size: 14px;
    min-height: 770px;
    overflow: hidden;
    .imgArea{
      background-color: #ffffff !important;
      border-top: inset #66666677;
      margin-top: 4px;
      font-size: 14px;
      p{
        text-align: center;
        img{
          width: 40%;
          padding: 5px;
        }
      }
      .textArea{
        min-height: 30px;
      }
    }
  }
  .el-footer {
    padding: 0 20px;
    box-sizing: border-box;
    flex-shrink: 0;
    height: unset;
    font-size: 14px;
  }

  .font14{
    font-size: 14px;
  }
}
#imgtxtrpt::-webkit-scrollbar {
   display: none;
 }
</style>

